#include <cctype>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <map>
using namespace std;

class dictionary{
public:
    bool is_word(string &word){
        for(auto c:word){
            if(!isalpha(c)){
                return false;
            }
        }
        return true;
    }
    void read_file(const string & pathname){
        ifstream ifs(pathname);
        string line;
        while(getline(ifs,line)){
            string word;
            istringstream iss(line);
            while(iss >> word){
                if(is_word(word)){
                    word_count[word] +=1;
                }
            }
        }
    }
    void write_to_file(const string & pathname){
        ofstream ofs(pathname);
        for(auto i:word_count){
            ofs<<i.first<<":"<<i.second<<endl;
        }
    }

private:
    map<string,int> word_count;
};

void test(){
    dictionary dict;
    dict.read_file("The_Holy_Bible.txt");
    dict.write_to_file("word_count.data");
}

int main()
{
    

    test ();
    return 0;
}

